# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=qscintilla-qt3
pkgver=1.7.1
pkgrel=1
pkgdesc="A port to Qt3 of Neil Hodgson's Scintilla C++ editor class."
arch=('x86_64' 'aarch64')
url='http://www.riverbankcomputing.co.uk/software/qscintilla/intro/'
license=('GPL2')
depends=('qt3')
source=("http://downloads.sourceforge.net/pyqt/QScintilla-1.71-gpl-$pkgver.tar.gz"
        "pro.patch")
sha512sums=('2db07d10eb24472584cc69ba3618205aead601b9d9c0c638081be0efca98e792578532b749a5ec41451158ef072d486a6000d863c5f7e65463dd56f9f68f69ef'
            'faaae8994c003031ec3d66248830c22a8b5f093e2c10171847df0c28d86a4835af0dcfff11d4f3eec74b92f81789b8cc5abc7f0ee9f08370a01f83d1feb85e8e')

_dir="QScintilla-1.71-gpl-$pkgver/qt"

prepare() {
  cd "$_dir"

  patch -p1 -i '../../pro.patch'
}

build() {
  cd "$_dir"

  qmake-qt3 qscintilla.pro

  make MOC=/usr/bin/moc-qt3 UIC=/usr/bin/uic-qt3
}

package() {
  cd "$_dir"

  dlib=`grep 'TARGETD\s=' Makefile | sed 's/.*=\s*\(.*\)/\1/'`
  sym0=`grep 'TARGET0\s=' Makefile | sed 's/.*=\s*\(.*\)/\1/'`
  sym1=`grep 'TARGET1\s=' Makefile | sed 's/.*=\s*\(.*\)/\1/'`
  sym2=`grep 'TARGET2\s=' Makefile | sed 's/.*=\s*\(.*\)/\1/'`

  install -Dm 755 "$dlib" "$pkgdir"/usr/lib/"$dlib"

  ln -sr "$pkgdir/usr/lib/$dlib" "$pkgdir/usr/lib/$sym0"
  ln -sr "$pkgdir/usr/lib/$dlib" "$pkgdir/usr/lib/$sym1"
  ln -sr "$pkgdir/usr/lib/$dlib" "$pkgdir/usr/lib/$sym2"

  make INSTALL_ROOT="$pkgdir" MOC=/usr/bin/moc-qt3 UIC=/usr/bin/uic-qt3 install
}

